home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
view JSON data
|
view as text
This file was processed as: LaTeX Document
(document/latex).
You can browse this item here: libgetopt.tex
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| LaTeX Document (document/latex)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| LaTeX document text
| default
| |
99%
| file
| LaTeX document, ASCII text, with CR line terminators
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/281 LaTeX (Subdocument)
| default
| |
100%
| detectItEasy
| Format: plain text[CR]
| default (weak)
|
|
id metadata |
---|
key | value |
---|
macFileType | [TEXT] |
macFileCreator | [R*ch] |
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 73 65 63 74 69 6f 6e | 7b 53 74 61 6e 64 61 72 |\section|{Standar|
|00000010| 64 20 4d 6f 64 75 6c 65 | 20 5c 73 65 63 74 63 6f |d Module| \sectco|
|00000020| 64 65 7b 67 65 74 6f 70 | 74 7d 7d 0d 0d 5c 73 74 |de{getop|t}}..\st|
|00000030| 6d 6f 64 69 6e 64 65 78 | 7b 67 65 74 6f 70 74 7d |modindex|{getopt}|
|00000040| 0d 54 68 69 73 20 6d 6f | 64 75 6c 65 20 68 65 6c |.This mo|dule hel|
|00000050| 70 73 20 73 63 72 69 70 | 74 73 20 74 6f 20 70 61 |ps scrip|ts to pa|
|00000060| 72 73 65 20 74 68 65 20 | 63 6f 6d 6d 61 6e 64 20 |rse the |command |
|00000070| 6c 69 6e 65 20 61 72 67 | 75 6d 65 6e 74 73 20 69 |line arg|uments i|
|00000080| 6e 0d 5c 63 6f 64 65 7b | 73 79 73 2e 61 72 67 76 |n.\code{|sys.argv|
|00000090| 7d 2e 0d 49 74 20 75 73 | 65 73 20 74 68 65 20 73 |}..It us|es the s|
|000000a0| 61 6d 65 20 63 6f 6e 76 | 65 6e 74 69 6f 6e 73 20 |ame conv|entions |
|000000b0| 61 73 20 74 68 65 20 5c | 55 4e 49 58 7b 7d 0d 5c |as the \|UNIX{}.\|
|000000c0| 63 6f 64 65 7b 67 65 74 | 6f 70 74 28 29 7d 0d 66 |code{get|opt()}.f|
|000000d0| 75 6e 63 74 69 6f 6e 2e | 0d 49 74 20 64 65 66 69 |unction.|.It defi|
|000000e0| 6e 65 73 20 74 68 65 20 | 66 75 6e 63 74 69 6f 6e |nes the |function|
|000000f0| 0d 5c 63 6f 64 65 7b 67 | 65 74 6f 70 74 2e 67 65 |.\code{g|etopt.ge|
|00000100| 74 6f 70 74 28 61 72 67 | 73 2c 20 6f 70 74 69 6f |topt(arg|s, optio|
|00000110| 6e 73 29 7d 0d 61 6e 64 | 20 74 68 65 20 65 78 63 |ns)}.and| the exc|
|00000120| 65 70 74 69 6f 6e 0d 5c | 63 6f 64 65 7b 67 65 74 |eption.\|code{get|
|00000130| 6f 70 74 2e 65 72 72 6f | 72 7d 2e 0d 0d 54 68 65 |opt.erro|r}...The|
|00000140| 20 66 69 72 73 74 20 61 | 72 67 75 6d 65 6e 74 20 | first a|rgument |
|00000150| 74 6f 0d 5c 63 6f 64 65 | 7b 67 65 74 6f 70 74 28 |to.\code|{getopt(|
|00000160| 29 7d 0d 69 73 20 74 68 | 65 20 61 72 67 75 6d 65 |)}.is th|e argume|
|00000170| 6e 74 20 6c 69 73 74 20 | 70 61 73 73 65 64 20 74 |nt list |passed t|
|00000180| 6f 20 74 68 65 20 73 63 | 72 69 70 74 20 77 69 74 |o the sc|ript wit|
|00000190| 68 20 69 74 73 20 66 69 | 72 73 74 20 65 6c 65 6d |h its fi|rst elem|
|000001a0| 65 6e 74 0d 63 68 6f 70 | 70 65 64 20 6f 66 66 20 |ent.chop|ped off |
|000001b0| 28 69 2e 65 2e 2c 0d 5c | 63 6f 64 65 7b 73 79 73 |(i.e.,.\|code{sys|
|000001c0| 2e 61 72 67 76 5b 31 3a | 5d 7d 29 2e 0d 54 68 65 |.argv[1:|]})..The|
|000001d0| 20 73 65 63 6f 6e 64 20 | 61 72 67 75 6d 65 6e 74 | second |argument|
|000001e0| 20 69 73 20 74 68 65 20 | 73 74 72 69 6e 67 20 6f | is the |string o|
|000001f0| 66 20 6f 70 74 69 6f 6e | 20 6c 65 74 74 65 72 73 |f option| letters|
|00000200| 20 74 68 61 74 20 74 68 | 65 0d 73 63 72 69 70 74 | that th|e.script|
|00000210| 20 77 61 6e 74 73 20 74 | 6f 20 72 65 63 6f 67 6e | wants t|o recogn|
|00000220| 69 7a 65 2c 20 77 69 74 | 68 20 6f 70 74 69 6f 6e |ize, wit|h option|
|00000230| 73 20 74 68 61 74 20 72 | 65 71 75 69 72 65 20 61 |s that r|equire a|
|00000240| 6e 20 61 72 67 75 6d 65 | 6e 74 0d 66 6f 6c 6c 6f |n argume|nt.follo|
|00000250| 77 65 64 20 62 79 20 61 | 20 63 6f 6c 6f 6e 20 28 |wed by a| colon (|
|00000260| 69 2e 65 2e 2c 20 74 68 | 65 20 73 61 6d 65 20 66 |i.e., th|e same f|
|00000270| 6f 72 6d 61 74 20 74 68 | 61 74 20 5c 55 4e 49 58 |ormat th|at \UNIX|
|00000280| 7b 7d 0d 5c 63 6f 64 65 | 7b 67 65 74 6f 70 74 28 |{}.\code|{getopt(|
|00000290| 29 7d 0d 75 73 65 73 29 | 2e 0d 54 68 65 20 72 65 |)}.uses)|..The re|
|000002a0| 74 75 72 6e 20 76 61 6c | 75 65 20 63 6f 6e 73 69 |turn val|ue consi|
|000002b0| 73 74 73 20 6f 66 20 74 | 77 6f 20 65 6c 65 6d 65 |sts of t|wo eleme|
|000002c0| 6e 74 73 3a 20 74 68 65 | 20 66 69 72 73 74 20 69 |nts: the| first i|
|000002d0| 73 20 61 20 6c 69 73 74 | 20 6f 66 0d 6f 70 74 69 |s a list| of.opti|
|000002e0| 6f 6e 2d 61 6e 64 2d 76 | 61 6c 75 65 20 70 61 69 |on-and-v|alue pai|
|000002f0| 72 73 3b 20 74 68 65 20 | 73 65 63 6f 6e 64 20 69 |rs; the |second i|
|00000300| 73 20 74 68 65 20 6c 69 | 73 74 20 6f 66 20 70 72 |s the li|st of pr|
|00000310| 6f 67 72 61 6d 20 61 72 | 67 75 6d 65 6e 74 73 0d |ogram ar|guments.|
|00000320| 6c 65 66 74 20 61 66 74 | 65 72 20 74 68 65 20 6f |left aft|er the o|
|00000330| 70 74 69 6f 6e 20 6c 69 | 73 74 20 77 61 73 20 73 |ption li|st was s|
|00000340| 74 72 69 70 70 65 64 20 | 28 74 68 69 73 20 69 73 |tripped |(this is|
|00000350| 20 61 20 74 72 61 69 6c | 69 6e 67 20 73 6c 69 63 | a trail|ing slic|
|00000360| 65 20 6f 66 20 74 68 65 | 0d 66 69 72 73 74 20 61 |e of the|.first a|
|00000370| 72 67 75 6d 65 6e 74 29 | 2e 0d 45 61 63 68 20 6f |rgument)|..Each o|
|00000380| 70 74 69 6f 6e 2d 61 6e | 64 2d 76 61 6c 75 65 20 |ption-an|d-value |
|00000390| 70 61 69 72 20 72 65 74 | 75 72 6e 65 64 20 68 61 |pair ret|urned ha|
|000003a0| 73 20 74 68 65 20 6f 70 | 74 69 6f 6e 20 61 73 20 |s the op|tion as |
|000003b0| 69 74 73 20 66 69 72 73 | 74 20 65 6c 65 6d 65 6e |its firs|t elemen|
|000003c0| 74 2c 0d 70 72 65 66 69 | 78 65 64 20 77 69 74 68 |t,.prefi|xed with|
|000003d0| 20 61 20 68 79 70 68 65 | 6e 20 28 65 2e 67 2e 2c | a hyphe|n (e.g.,|
|000003e0| 0d 5c 63 6f 64 65 7b 27 | 2d 78 27 7d 29 2c 0d 61 |.\code{'|-x'}),.a|
|000003f0| 6e 64 20 74 68 65 20 6f | 70 74 69 6f 6e 20 61 72 |nd the o|ption ar|
|00000400| 67 75 6d 65 6e 74 20 61 | 73 20 69 74 73 20 73 65 |gument a|s its se|
|00000410| 63 6f 6e 64 20 65 6c 65 | 6d 65 6e 74 2c 20 6f 72 |cond ele|ment, or|
|00000420| 20 61 6e 20 65 6d 70 74 | 79 20 73 74 72 69 6e 67 | an empt|y string|
|00000430| 20 69 66 20 74 68 65 0d | 6f 70 74 69 6f 6e 20 68 | if the.|option h|
|00000440| 61 73 20 6e 6f 20 61 72 | 67 75 6d 65 6e 74 2e 0d |as no ar|gument..|
|00000450| 54 68 65 20 6f 70 74 69 | 6f 6e 73 20 6f 63 63 75 |The opti|ons occu|
|00000460| 72 20 69 6e 20 74 68 65 | 20 6c 69 73 74 20 69 6e |r in the| list in|
|00000470| 20 74 68 65 20 73 61 6d | 65 20 6f 72 64 65 72 20 | the sam|e order |
|00000480| 69 6e 20 77 68 69 63 68 | 20 74 68 65 79 20 77 65 |in which| they we|
|00000490| 72 65 0d 66 6f 75 6e 64 | 2c 20 74 68 75 73 20 61 |re.found|, thus a|
|000004a0| 6c 6c 6f 77 69 6e 67 20 | 6d 75 6c 74 69 70 6c 65 |llowing |multiple|
|000004b0| 20 6f 63 63 75 72 72 65 | 6e 63 65 73 2e 0d 45 78 | occurre|nces..Ex|
|000004c0| 61 6d 70 6c 65 3a 0d 0d | 5c 62 63 6f 64 65 5c 62 |ample:..|\bcode\b|
|000004d0| 65 67 69 6e 7b 76 65 72 | 62 61 74 69 6d 7d 0d 3e |egin{ver|batim}.>|
|000004e0| 3e 3e 20 69 6d 70 6f 72 | 74 20 67 65 74 6f 70 74 |>> impor|t getopt|
|000004f0| 2c 20 73 74 72 69 6e 67 | 0d 3e 3e 3e 20 61 72 67 |, string|.>>> arg|
|00000500| 73 20 3d 20 73 74 72 69 | 6e 67 2e 73 70 6c 69 74 |s = stri|ng.split|
|00000510| 28 27 2d 61 20 2d 62 20 | 2d 63 66 6f 6f 20 2d 64 |('-a -b |-cfoo -d|
|00000520| 20 62 61 72 20 61 31 20 | 61 32 27 29 0d 3e 3e 3e | bar a1 |a2').>>>|
|00000530| 20 61 72 67 73 0d 5b 27 | 2d 61 27 2c 20 27 2d 62 | args.['|-a', '-b|
|00000540| 27 2c 20 27 2d 63 66 6f | 6f 27 2c 20 27 2d 64 27 |', '-cfo|o', '-d'|
|00000550| 2c 20 27 62 61 72 27 2c | 20 27 61 31 27 2c 20 27 |, 'bar',| 'a1', '|
|00000560| 61 32 27 5d 0d 3e 3e 3e | 20 6f 70 74 6c 69 73 74 |a2'].>>>| optlist|
|00000570| 2c 20 61 72 67 73 20 3d | 20 67 65 74 6f 70 74 2e |, args =| getopt.|
|00000580| 67 65 74 6f 70 74 28 61 | 72 67 73 2c 20 27 61 62 |getopt(a|rgs, 'ab|
|00000590| 63 3a 64 3a 27 29 0d 3e | 3e 3e 20 6f 70 74 6c 69 |c:d:').>|>> optli|
|000005a0| 73 74 0d 5b 28 27 2d 61 | 27 2c 20 27 27 29 2c 20 |st.[('-a|', ''), |
|000005b0| 28 27 2d 62 27 2c 20 27 | 27 29 2c 20 28 27 2d 63 |('-b', '|'), ('-c|
|000005c0| 27 2c 20 27 66 6f 6f 27 | 29 2c 20 28 27 2d 64 27 |', 'foo'|), ('-d'|
|000005d0| 2c 20 27 62 61 72 27 29 | 5d 0d 3e 3e 3e 20 61 72 |, 'bar')|].>>> ar|
|000005e0| 67 73 0d 5b 27 61 31 27 | 2c 20 27 61 32 27 5d 0d |gs.['a1'|, 'a2'].|
|000005f0| 3e 3e 3e 20 0d 5c 65 6e | 64 7b 76 65 72 62 61 74 |>>> .\en|d{verbat|
|00000600| 69 6d 7d 5c 65 63 6f 64 | 65 0d 0d 54 68 65 20 65 |im}\ecod|e..The e|
|00000610| 78 63 65 70 74 69 6f 6e | 0d 5c 63 6f 64 65 7b 67 |xception|.\code{g|
|00000620| 65 74 6f 70 74 2e 65 72 | 72 6f 72 20 3d 20 27 67 |etopt.er|ror = 'g|
|00000630| 65 74 6f 70 74 20 65 72 | 72 6f 72 27 7d 0d 69 73 |etopt er|ror'}.is|
|00000640| 20 72 61 69 73 65 64 20 | 77 68 65 6e 20 61 6e 20 | raised |when an |
|00000650| 75 6e 72 65 63 6f 67 6e | 69 7a 65 64 20 6f 70 74 |unrecogn|ized opt|
|00000660| 69 6f 6e 20 69 73 20 66 | 6f 75 6e 64 20 69 6e 20 |ion is f|ound in |
|00000670| 74 68 65 20 61 72 67 75 | 6d 65 6e 74 20 6c 69 73 |the argu|ment lis|
|00000680| 74 20 6f 72 0d 77 68 65 | 6e 20 61 6e 20 6f 70 74 |t or.whe|n an opt|
|00000690| 69 6f 6e 20 72 65 71 75 | 69 72 69 6e 67 20 61 6e |ion requ|iring an|
|000006a0| 20 61 72 67 75 6d 65 6e | 74 20 69 73 20 67 69 76 | argumen|t is giv|
|000006b0| 65 6e 20 6e 6f 6e 65 2e | 0d 54 68 65 20 61 72 67 |en none.|.The arg|
|000006c0| 75 6d 65 6e 74 20 74 6f | 20 74 68 65 20 65 78 63 |ument to| the exc|
|000006d0| 65 70 74 69 6f 6e 20 69 | 73 20 61 20 73 74 72 69 |eption i|s a stri|
|000006e0| 6e 67 20 69 6e 64 69 63 | 61 74 69 6e 67 20 74 68 |ng indic|ating th|
|000006f0| 65 20 63 61 75 73 65 20 | 6f 66 20 74 68 65 0d 65 |e cause |of the.e|
|00000700| 72 72 6f 72 2e 0d | |rror.. | |
+--------+-------------------------+-------------------------+--------+--------+